<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\RowAction;

class RouteAction extends RowAction {
	public $name = '图书排名';
	public $type_id;

	public function __construct($type_id) {
		switch ($type_id) {
		case '1':
			$this->name = '图书排名';
			break;
		case '2':
			$this->name = '多抓鱼地址';
			break;
		case '3':
			$this->name = '商品详情';
			break;
		}
		$this->type_id = $type_id;
	}

	public function href() {
		switch ($this->type_id) {
		case '1':
			$shop_id = $this->row->shop_id;
			$url = route('topBook.index') . '?shop_id=' . $shop_id;
			break;
		case '2':
			$url = "https://www.duozhuayu.com/search/" . $this->row->title;
			break;
		case '3':
			$url = route('goods.show', ['goods' => $this->getKey()]);
			break;

		}
		return $url;

	}

}
